#include "Ctrl.h"

#if TemplateMethod_

class AbstractClass 
{
public:
	AbstractClass() {}
	~AbstractClass(){}

	virtual void PrimitiveOperation1()=0;
	virtual void PrimitiveOperation2()=0;

	void TemplateMethod() {
		PrimitiveOperation1();
		PrimitiveOperation2();
		printf("TemplateMethod\r\n");
	}
};


class ConcreteClassA : public AbstractClass
{
public:
	void PrimitiveOperation1()override {
		printf("具体类A方法1实现\r\n");
	}
	void PrimitiveOperation2()override {
		printf("具体类A方法2实现\r\n");
	}
};

class ConcreteClassB : public AbstractClass
{
public:
	void PrimitiveOperation1()override {
		printf("具体类B方法1实现\r\n");
	}
	void PrimitiveOperation2()override {
		printf("具体类B方法2实现\r\n");
	}
};


int main() {
	AbstractClass* c;
	c = new ConcreteClassA();
	c->TemplateMethod();

	c = new ConcreteClassB();
	c->TemplateMethod();
}



#endif